<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Register</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/mycss.css" rel="stylesheet">
</head>
<body>
<div class="container">
    <div class="row">
        <div class="col-md-offset-3 col-md-6">
            <form class="form-horizontal">
                <span class="heading">用户注册</span>
                <div class="form-group">
                    <input type="text" class="form-control required" name="username" id="uname" placeholder="用户名"
                           required>
                </div>
                <div class="form-group">
                    <input type="password" class="form-control" name="password" id="pwd" placeholder="密　码" required>
                </div>
                <div class="form-group">
                    <input type="email" class="form-control" name="email" id="email" placeholder="邮 箱" required>
                </div>
                <div class="form-group">
                    <input type="text" class="form-control" name="phone" id="phone" placeholder="电话号码" required>
                </div>
                <div class="form-group">
                    <button type="button" class="btn btn-default" id="r2">前往登录</button>
                    <button type="button" class="btn btn-default" id="r1">注册</button>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="js/jquery-3.5.1.js"></script>
<script type="text/javascript">
    $("#r1").click(function () {
        var username = $("#uname").val();
        var password = $("#pwd").val();
        var email = $("#email").val();
        var phone = $("#phone").val();
        $.post("user/register", {username: username, password: password, email: email, phone: phone},
            function (data) {
            if (data.state === 1) {
                alert("注册成功")
            } else {
                alert("注册失败，请重试")
            }
        });
    });
    $("#r2").click(function () {
        window.location.href = "Login.html";
    })
</script>
</body>
</html>